var xmlHttp

function getData(param)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request");
 		return;
 	}

	var url="";

	switch(param)
	{
		case "login":
			url="saveData.php";
			url=url+"?q="+param+"&sid="+Math.random();
			xmlHttp.onreadystatechange=loggedIn; 
			break;

		case "logout":
			url="saveData.php";
			url=url+"?q="+param+"&sid="+Math.random();
			xmlHttp.onreadystatechange=loggedOut; 
			break;

		case "register":
			url="user.php";
			url=url+"?q="+param+"&sid="+Math.random();
			xmlHttp.onreadystatechange=registered; 
			break;

		default:
			alert("Param not valid");
			return;
			break;
	}
	
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
 	{
 		// Firefox, Opera 8.0+, Safari
 		xmlHttp=new XMLHttpRequest();
 	}
	catch (e)
 	{
 		//Internet Explorer
 		try
  		{
  			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  		}
 		catch (e)
  		{
  		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
 	}
	return xmlHttp;
}